package com.duobaoyu.dby.supply.admin.controller.config;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.duobaoyu.dby.channel.adapter.enums.OperationTypeEnum;
import com.duobaoyu.dby.common.core.util.R;
import com.duobaoyu.dby.supply.admin.annotation.SupplySysLog;
import com.duobaoyu.dby.supply.biz.client.resource.ResourceExpressInfoAdminClient;
import com.duobaoyu.dby.supply.biz.client.resource.bean.dto.*;
import com.duobaoyu.dby.supply.biz.client.resource.bean.vo.ExpressInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 物流公司管理
 * @author jz
 * @version 1.0
 * @date 2022/7/29 20:56
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/admin/express-info")
@Api(value = "express-info", tags = "物流公司")
public class ExpressInfoController {

	private final ResourceExpressInfoAdminClient resourceExpressInfoAdminClient;

	/**
	 * 物流公司列表
	 *
	 * @param expressInfoQuery
	 * @return
	 */
	@GetMapping("/page")
	@ApiOperation(value = "物流公司列表", notes = "物流公司列表")
	@SupplySysLog(value = "物流公司列表",operationType = OperationTypeEnum.SELECT)
	public R<Page<ExpressInfoVO>> page(ExpressInfoQueryDTO expressInfoQuery) {

		return R.ok(resourceExpressInfoAdminClient.page(expressInfoQuery));
	}

	/**
	 * 物流公司保存
	 *
	 * @param expressInfoSave
	 * @return
	 */
	@PostMapping("/saveExpressInfo")
	@ApiOperation(value = "物流公司保存", notes = "物流公司保存")
	@SupplySysLog(value = "物流公司保存",operationType = OperationTypeEnum.INTERT)
	public R<Boolean> saveExpressInfo(@Validated @RequestBody ExpressInfoSaveDTO expressInfoSave) {

		return R.ok(resourceExpressInfoAdminClient.saveExpressInfo(expressInfoSave));
	}

	/**
	 * 物流公司更新
	 *
	 * @param expressInfoUpdate
	 * @return
	 */
	@PostMapping("/updateExpressInfo")
	@ApiOperation(value = "物流公司更新", notes = "物流公司更新")
	@SupplySysLog(value = "物流公司更新",operationType = OperationTypeEnum.UPDATE)
	public R<Boolean> updateExpressInfo(@Validated @RequestBody ExpressInfoUpdateDTO expressInfoUpdate) {

		return R.ok(resourceExpressInfoAdminClient.updateExpressInfo(expressInfoUpdate));
	}

	/**
	 * 物流公司状态变更
	 *
	 * @param expressInfoStatus
	 * @return
	 */
	@PostMapping("/updateStatus")
	@ApiOperation(value = "物流公司状态变更", notes = "物流公司状态变更")
	@SupplySysLog(value = "物流公司状态变更",operationType = OperationTypeEnum.UPDATE)
	public R<Boolean> updateStatus(@Validated @RequestBody ExpressInfoStatusDTO expressInfoStatus) {

		return R.ok(resourceExpressInfoAdminClient.updateStatus(expressInfoStatus));
	}

	/**
	 * 物流公司删除
	 *
	 * @param expressInfoDelete
	 * @return
	 */
	@PostMapping("/deleteExpressInfo")
	@ApiOperation(value = "物流公司删除", notes = "物流公司删除")
	@SupplySysLog(value = "物流公司删除",operationType = OperationTypeEnum.DELETE)
	public R<Boolean> deleteExpressInfo(@Validated @RequestBody ExpressInfoDeleteDTO expressInfoDelete) {

		return R.ok(resourceExpressInfoAdminClient.deleteExpressInfo(expressInfoDelete));
	}

}
